package com.hsyt.pms.support.common;

import com.alibaba.fastjson.JSON;
import com.hsyt.pfc.support.util.LoggerUtil;
import com.hsyt.pms.api.common.BaseParam;
import com.hsyt.pms.api.entity.system.SysFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ServiceResultUtils {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceResultUtils.class);

    public static <T> T analyze(BaseParam baseParam, Class<T> clazz) {
        try {
            if (null == baseParam) {
                return null;
            }
            return JSON.parseObject(JSON.toJSONString(baseParam), clazz);
        } catch (Exception e) {
            LoggerUtil.error(LOGGER, "msg:{1}", e.getMessage());
            return null;
        }
    }

    public static void main(String[] args) {
        BaseParam baseParam = null;
        SysFunction a = JSON.parseObject(JSON.toJSONString(baseParam), SysFunction.class);
        System.out.println(a.toString());
    }

}
